<?php

namespace App\Rules;

use Illuminate\Contracts\Validation\Rule;
//自定义验证规则
class AccountRule implements Rule
{

    public function __construct()
    {
        //
    }


    public function passes($attribute, $value)
    {
        //
        return
            filter_var($value, FILTER_VALIDATE_EMAIL)
            ||
            preg_match('/^1\d{10}$/i', $value);
    }

    /**
     * Get the validation error message.
     *
     * @return string
     */
    public function message()
    {
        return '账号格式错误';
    }
}
